#!/bin/sh

#-------------------------------------------------------------------
#
# Preinstall shell script for Witango Application Server 5.5
#
#  CS: 20040403  Initial Build
#  CS: 20050321  Tiger Support Added
#-------------------------------------------------------------------

echo "Pre Upgrade"
OS_VER=`uname -r`
if [ "$OS_VER"=8.0.0 ] ; then
	echo "Installing on Jaguar" $OS_VER
elif [ "$OS_VER"=6.8 ] ; then
	echo "Installing on Jaguar" $OS_VER
elif [ "$OS_VER"=7.3 ] ; then
	echo "Installing on Panther" $OS_VER
else
	echo "Installing on unknows OS X version" $OS_VER
fi

export WITANGO_PATH=/Applications/WitangoServer/5.5

echo "Stop the Witango Server if it is running"
if [ -f "$WITANGO_PATH/witangod" ] ; then
	SystemStarter stop WITANGO55
fi

echo "Remove previous backup of the witango configuration files before installation"
if [ -d "$WITANGO_PATH/configuration.bkp" ] ; then
	/bin/rm -R $WITANGO_PATH/configuration.bkp
fi

echo "Backup the current witango configuration files before installation"
if [ -d "$WITANGO_PATH/configuration" ] ; then
	/bin/cp -R -f -p $WITANGO_PATH/configuration $WITANGO_PATH/configuration.bkp
fi

echo "Prep StartupItems directory in case it does not exist - pre 10.4 bug"
if [ ! -d "/Library/StartupItems" ] ; then
	/bin/mkdir /Library/StartupItems
fi
